﻿[assembly:
        System.Web.UI.WebResource("BM.Tools.WebControls.MForm.Controls.Additions.BubbleTooltipAddition.js",
                "application/x-javascript")]
[assembly:
        System.Web.UI.WebResource("BM.Tools.WebControls.MForm.Controls.Additions.BubbleTooltipAddition.debug.js",
                "application/x-javascript")]

namespace BM.Tools.WebControls.MForm.Controls.Additions
{
    using AjaxControlToolkit;

    using BM.Tools.WebControls.MForm.Controls.Helper;
    using BM.Tools.WebControls.MForm.Controls.Items;
    using BM.Tools.WebControls.MForm.Generator;

    /// <summary>
    /// This addition adds a simple bubble tooltip near the leaf item
    /// </summary>
    [ClientScriptResource("BM.Tools.WebControls.MForm",
            "BM.Tools.WebControls.MForm.Controls.Additions.BubbleTooltipAddition.js")]
    [ClientScriptResource("BM.Tools.WebControls.MForm",
            "BM.Tools.WebControls.MForm.Controls.Iframe.js")]
    [ClientScriptResource("BM.Tools.WebControls.MForm",
            "BM.Tools.WebControls.MForm.Controls.FieldConstraints.js")]
    public class BubbleTooltipAddition : Addition
    {
        /// <summary>
        /// adds the bubble tooltip on creating child controls
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            if (Owner.Mode.Equals(FormBuilderMode.Edit))
            {
                (Owner as LeafItem).AfterValueHandlerHolder.Controls.AddAt(0, new BubbleTooltip());
            }
        }
    }
}